#ifndef WEATHERDATA_HPP_
#define WEATHERDATA_HPP_

#include "Display.hpp"

class WeatherData
{
private:
  CurrentConditionDisplay* _current;
  StatisticsDisplay* _statistics;
  ForecastDisplay* _forecast;

  float GetTemperature()
  {
    // 获取温度
    // std::cout << "温度：" << temp << std::endl;
  
    float temp = rand() % 10 + 10;
    return temp;
  }

  float GetHumidity()
  {
    // 获取湿度
    // std::cout << "湿度：" << humidity << std::endl;
    float humidity = rand() % 20 + 40;
    return humidity;
  }

  float GetPressure()
  {
    // 获取气压
    // std::cout << "气压：" << pressure << std::endl;

    float pressure = rand() % 10 + 95;
    return pressure;
  }

public:
  WeatherData()
    :_current(nullptr), _statistics(nullptr), _forecast(nullptr)
  {}

  WeatherData(CurrentConditionDisplay* current, StatisticsDisplay* statistics, ForecastDisplay* forecast)
    :_current(current), _statistics(statistics), _forecast(forecast)
  {}
  
  void MearsureChanged()
  {
    float temp = GetTemperature();
    float humidity = GetHumidity();
    float pressure = GetPressure();

    if(_current != nullptr)
      _current->Update(temp, humidity, pressure);

    if(_statistics != nullptr)
      _statistics->Update(temp, humidity, pressure);

    if(_forecast != nullptr)
      _forecast->Update(temp, humidity, pressure);

  }
};

#endif
